package com.hhs.storage.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hhs.storage.bean.BaseUser;
import com.hhs.storage.bean.InputParam;
import com.hhs.storage.bean.ResponseInfo;
import com.hhs.storage.bean.XmExtype;
import com.hhs.storage.service.XmExtypeService;
import com.hhs.storage.util.StringUtil;
import com.hhs.storage.util.SysUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chx
 * @since 2024-11-17
 */
@RestController
@RequestMapping("xmextype")
@Slf4j
public class XmExtypeController {
    @Resource
    XmExtypeService xmExtypeService;
    @RequestMapping("edit")
    public Map<String,Object> edit(XmExtype xmExtype){
        xmExtypeService.saveOrUpdate(xmExtype);
        return ResponseInfo.success();
    }
    @RequestMapping("table")
    public Map<String,Object> table(InputParam inputParam){
        Map map=new HashMap();
        QueryWrapper qw=new QueryWrapper();
        qw.orderByAsc("sort_id");
        inputParam.mapParams("name");
        if(!StringUtil.iszNull(inputParam.getName())){
            qw.like("name", inputParam.getName());
        }
        Page mp = xmExtypeService.page(new Page(inputParam.getPage(), inputParam.getSize()),qw);
        map.put("code",1);
        map.put("data",mp.getRecords());
        map.put("total",mp.getTotal());
        return map;
    }
    @RequestMapping("dele")
    public Map<String,Object> dele(XmExtype xmExtype){
        if(StringUtil.iszNull(xmExtype.getId())){
            return ResponseInfo.error("没有id,参数错误");
        }
        xmExtypeService.removeById(xmExtype.getId());
        return ResponseInfo.success();
    }
}

